package com.ruoyi.training.service.impl;

import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.training.domain.A03ResSupport;
import com.ruoyi.training.mapper.A03ResSupportMapper;
import com.ruoyi.training.service.IA03ResSupportService;
import com.ruoyi.training.util.xuehua.SnowflakeIdUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 供应商库Service业务层处理
 * 
 * @author WorrilessGo
 * @date 2025-11-18
 */
@Service
public class A03ResSupportServiceImpl implements IA03ResSupportService 
{
    @Resource
    private A03ResSupportMapper a03ResSupportMapper;

    /**
     * 查询供应商库
     * 
     * @param id 供应商库主键
     * @return 供应商库
     */
    @Override
    public A03ResSupport selectA03ResSupportById(String id)
    {
        return a03ResSupportMapper.selectA03ResSupportById(id);
    }

    /**
     * 查询供应商库列表
     * 
     * @param a03ResSupport 供应商库
     * @return 供应商库
     */
    @Override
    public List<A03ResSupport> selectA03ResSupportList(A03ResSupport a03ResSupport)
    {
        return a03ResSupportMapper.selectA03ResSupportList(a03ResSupport);
    }

    /**
     * 新增供应商库
     * 
     * @param a03ResSupport 供应商库
     * @return 结果
     */
    @Override
    public int insertA03ResSupport(A03ResSupport a03ResSupport)
    {
        String id = String.valueOf(new SnowflakeIdUtils(5, 8).nextId());
        a03ResSupport.setSupplierId(id);
        a03ResSupport.setCreateTime(DateUtils.getNowDate());
        return a03ResSupportMapper.insertA03ResSupport(a03ResSupport);
    }

    /**
     * 修改供应商库
     * 
     * @param a03ResSupport 供应商库
     * @return 结果
     */
    @Override
    public int updateA03ResSupport(A03ResSupport a03ResSupport)
    {
        a03ResSupport.setUpdateTime(DateUtils.getNowDate());
        return a03ResSupportMapper.updateA03ResSupport(a03ResSupport);
    }

    /**
     * 批量删除供应商库
     * 
     * @param ids 需要删除的供应商库主键
     * @return 结果
     */
    @Override
    public int deleteA03ResSupportByIds(String[] ids)
    {
        return a03ResSupportMapper.deleteA03ResSupportByIds(ids);
    }

    /**
     * 删除供应商库信息
     * 
     * @param id 供应商库主键
     * @return 结果
     */
    @Override
    public int deleteA03ResSupportById(String id)
    {
        return a03ResSupportMapper.deleteA03ResSupportById(id);
    }

    @Override
    public int batchInsertA03ResSupport(List<A03ResSupport> a03ResSupports) {
        a03ResSupports.forEach(s->{
            String id = String.valueOf(new SnowflakeIdUtils(5, 8).nextId());
            s.setSupplierId(id);
        });
        return a03ResSupportMapper.batchInsertA03ResSupport(a03ResSupports);
    }
}
